const modalTmpl = require("./tmpl/build/template");

var confirmModal = {
    init: function(){
        $("body").append(modalTmpl("modal", {}));
        $("#confirmModal").find("[data-cancel-del]").unbind("click").bind("click", ()=>{
            if(typeof this.cancelcallback === "function"){
                this.cancelcallback();
            }
        });
        $("#confirmModal").find("[data-submit-del]").unbind("click").bind("click", ()=>{
            if(typeof this.delcallback === "function"){
                this.delcallback();
            }
        });
    },
    show: function(delcallback, cancelcallback){
        $("#confirmModal").modal("show");
        this.cancelcallback = cancelcallback;
        this.delcallback = delcallback;
    },
    hide: function(){
        $("#confirmModal").modal("hide");
    }
};

export default confirmModal;